import React, { useRef } from 'react';

import { Divider, Input, Button } from 'antd'

const View: React.FC = () => {

    return (
        <>
            <Divider orientation="left">useRef</Divider>

            <p>用途：聚焦</p>
            <Comp1 />

        </>
    )
}


const Comp1 = () => {
    const inputRef = useRef<any>(null);

    function handleClick() {
        inputRef.current.focus();
    }

    return (
        <>
            <Input ref={inputRef} />
            <Button onClick={handleClick}>
                Focus the input
            </Button>
        </>
    );
}


export default View